<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>我的提交</title>
    <style>
        /* 全局样式 */
        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #e0f7fa, #f1f8e9);
            margin: 0;
            padding: 0;
            color: #333;
        }

        /* 导航栏样式 */
        .navbar {
            background-color: #263238;
            display: flex;
            justify-content: center;
            padding: 15px 0;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .navbar a {
            color: #e0f7fa;
            text-decoration: none;
            margin: 0 20px;
            font-size: 16px;
            transition: color 0.3s ease;
        }

        .navbar a:hover {
            color: #80cbc4;
        }

        /* 提交列表样式 */
        .submission-list {
            width: 90%;
            max-width: 1000px;
            margin: 50px auto;
            text-align: center;
            background-color: #ffffff;
            border-radius: 15px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            padding: 30px;
            animation: fadeIn 0.5s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .submission-list h1 {
            color: #263238;
            font-size: 32px;
            margin-bottom: 30px;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
        }

        .submission-list table {
            width: 100%;
            border-collapse: collapse;
        }

        .submission-list table th,
        .submission-list table td {
            padding: 15px 20px;
            border-bottom: 1px solid #e0e0e0;
            transition: background-color 0.3s ease;
        }

        .submission-list table th {
            background-color: #263238;
            color: #e0f7fa;
            text-transform: uppercase;
            font-size: 14px;
            letter-spacing: 1px;
        }

        .submission-list table tr:hover {
            background-color: #f1f8e9;
        }

        .status-passed {
            color: #4caf50;
            font-weight: bold;
        }

        .status-failed {
            color: #f44336;
            font-weight: bold;
        }

        .submission-list table td a {
            color: #009688;
            text-decoration: none;
            transition: color 0.3s ease;
        }

        .submission-list table td a:hover {
            color: #26a69a;
            text-decoration: underline;
        }
    </style>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap">
</head>

<body>
    <div class="container">
        <div class="navbar">
            <a href="/">首页</a>
            <a href="/all_questions">题库</a>
            <a class="login" id="logoutLink" href="/logout" style="display: none; position: absolute; right: 80px;">退出</a>
            <a class="login" id="loginLink" href="/login" style="position: absolute; right: 80px;">登录</a>
            <a href="/user/submissions">我的提交</a>
            <script>
                function checkLogin() {
                    // 1. 精准获取元素
                    const loginLink = document.getElementById('loginLink');
                    const logoutLink = document.getElementById('logoutLink');

                    // 2. 检查Cookie中是否有user_id
                    const isLoggedIn = document.cookie.split(';').some(cookie => {
                        cookie = cookie.trim();
                        if (cookie.startsWith('user_id=')) {
                            const value = cookie.substring(8); // 去掉 "user_id=" 前缀
                            return value && value !== "undefined" && value !== "null";
                        }
                        return false;
                    });

                    // 3. 根据登录状态切换显示
                    if (isLoggedIn) {
                        loginLink.style.display = 'none';
                        logoutLink.style.display = 'inline-block';
                    } else {
                        loginLink.style.display = 'inline-block';
                        logoutLink.style.display = 'none';
                    }
                }

                // 4. 确保DOM加载完成后执行
                document.addEventListener('DOMContentLoaded', checkLogin);
            </script>
        </div>
        <div class="submission-list">
            <h1>我的提交记录</h1>
            <table>
                <tr>
                    <th>题目编号</th>
                    <th>题目标题</th>
                    <th>难度</th>
                    <th>提交时间</th>
                    <th>状态</th>
                </tr>
                {{#submission_list}}
                <tr>
                    <td>{{number}}</td>
                    <td><a href="/question/{{number}}">{{title}}</a></td>
                    <td>{{star}}</td>
                    <td>{{submit_time}}</td>
                    <td class="{{status_class}}">{{status}}</td>
                </tr>
                {{/submission_list}}
            </table>
        </div>
    </div>
</body>

</html>